// const ExtractTextPlugin = require('extract-text-webpack-plugin')
const path = require('path')

module.exports = {
    // mode: 'development',
    entry: {
        index: './src/index.js',
        main: './src/main.js',
        index1: './src/index1.js'
    },
    // entry: './src/index.js',
    output: {
        path: path.resolve(__dirname,'./build'),
        // filename: '[name].[hash:5].js',
        filename: '[name].bundle.js',
        // chunkFilename: '[name].chunk.js',
    },
    module: {
        rules: [{
                test: /\.js?$/,
                exclude: /(node_modules)/,
                use: 'babel-loader'
            },
            {
                test: /\.css$/,
                use: ['style-loader', {
                    loader: 'css-loader',
                    options: {
                        modules: true
                    }
                }]
            }
            // ,
            // {
            //     test: /\.css$/,
            //     use: ExtractTextPlugin.extract({
            //         fallback: 'style-loader',
            //         use: [{
            //             loader: 'css-loader',
            //             options: {
            //                 modules: true
            //             }
            //         }]
            //     })
            // }
        ]
    },
    resolve: {
        modules: ["node_modules"],
        extensions: [".js", ".json", ".jsx", ".css"],
        alias: {
            // '$': 'jquery'
        }
    },
    optimization: {
        splitChunks: {
            chunks: 'all',
            name: true,
            minChunks: 1,
            minSize: 10,
            // automaticNameDelimiter: '-'
            cacheGroups:{
                vendors:{
                    test: /node_modules/,
                    name: 'vendor',
                    priority: -10
                },
                default: {
                    // name: 'common',
                    minChunks: 2,
                    priority: -20,
                    reuseExistingChunk: true,
                }
            }
        },
        // runtimeChunk: true,
        runtimeChunk: {
            name: 'runtime'
        },

    }
    // plugin: [
    //     // new ExtractTextPlugin()
    // ]
}
